//
//  SecondViewController.m
//  BangoiOSSDKTestApp
//
//  Created by Development Bango on 12/06/2013.
//  Copyright (c) 2013 Development Bango. All rights reserved.
//

#import "SecondViewController.h"
#import "AppDelegate.h"
#import "BGOProfile.h"
#import "BGOAnalyticsManager.h"
#import "BGOAnalyticsConstants.h"
#import "BangoConfigConstants.h"
#import "BGOTransmissionModeConstants.h"
#import "BGODataType.h"
#import "BGOEvent.h"
#import "BGOEventParameter.h"
#import "BGOPersistenceManager.h"
#import "LoggingLevelView.h"

@interface SecondViewController ()

@end

@implementation SecondViewController
@synthesize doneBtn, viewBatchTViPhone, profiles;

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    NSLog(@"> %s", __PRETTY_FUNCTION__);
    self.profiles = [[BGOPersistenceManager sharedPersistenceManager] getProfilesForPost:NO bangoUserId:[BGOAnalyticsManager sharedManager].bangoUserId];
   NSMutableString *textViewText = [NSMutableString string];
    if(self.profiles == nil){
        [textViewText appendString:@"No events for this profile"];
    }
    else{
        for(BGOProfile *profile in self.profiles){
            [textViewText appendFormat:@"%@", profile.applicationKey];
            [textViewText appendFormat:@" Events: %lu", (unsigned long)profile.events.count];
            [textViewText appendString:@"\n"];
            for(BGOEvent *event in profile.events){
                [textViewText appendFormat:@" %@", event.eventName];
                [textViewText appendString:@"\n"];
            }
            [textViewText appendString:@"\n"];
        }
    }
    self.viewBatchTViPhone.text = textViewText;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)doneBtnPressed:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
}
@end
